home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
COMAL
/
B-Book Series
/
(k)b4.d64
/
example11.6
< prev
next >
Wrap
Text File
|
2007-02-28
|
1KB
|
37 lines
0010 DIM INFO$(7) OF 5, LEFT'(7), RIGHT'(7), PARENT(7), VISIT(0:7)
0020 FOR K:=1 TO 7 DO READ INFO$(K),LEFT'(K),RIGHT'(K),PARENT(K)
0030 FOR K:=1 TO 7 DO VISIT(K):=0
0040 NODE:=1
0050 WHILE NODE<>0 DO
0060 IF VISIT(NODE)=0 THEN PRINT INFO$(NODE)
0070 VISIT(NODE):=VISIT(NODE)+1
0080 IF LEFT'(NODE)<>0 AND VISIT(LEFT'(NODE))=0 THEN
0090 NODE:=LEFT'(NODE)
0100 ELIF RIGHT'(NODE)<>0 AND VISIT(RIGHT'(NODE))=0 THEN
0110 NODE:=RIGHT'(NODE)
0120 ELIF PARENT(NODE)<>0 THEN
0130 NODE:=PARENT(NODE)
0140 PARENTNODE
0150 ENDIF
0160 ENDWHILE
0170 PROC PARENTNODE
0180 CASE VISIT(NODE) OF
0190 WHEN 1
0200 IF INFO$(NODE)="IF" THEN PRINT "ELSE"
0210 VISIT(NODE):=VISIT(NODE)+1
0220 NODE:=RIGHT'(NODE)
0230 WHEN 2
0240 IF INFO$(NODE)="IF" THEN PRINT "ENDIF"
0250 IF INFO$(NODE)="FOR" THEN PRINT "NEXT"
0260 VISIT(NODE):=VISIT(NODE)+1
0270 NODE:=PARENT(NODE)
0280 ENDCASE
0290 ENDPROC PARENTNODE
0300 DATA "TVSIM",2,7,0
0310 DATA "FOR",3,4,1
0320 DATA "IF",5,6,2
0330 DATA "THREE",0,0,2
0340 DATA "ONE",0,0,3
0350 DATA "TWO",0,0,3
0360 DATA "PRINT",0,0,1